/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.chl.cid.beans;

import edu.chl.cid.entities.Product;
import java.beans.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

/**
 *
 * @author rhodinj
 */
@ManagedBean
@RequestScoped
public class ProductController {

    @EJB
    private ProductEJB productEJB;

    private Product product = new Product();
    private List<Product> productList = new ArrayList<Product>();

    public String doCreateProduct() {
        product = productEJB.createProduct(product);
        productList = productEJB.findProducts();
        return "success";
    }

    public Product getProduct() {
        return product;
    }

    public Product getProduct(String name) {
        return productEJB.getProductByName(name);
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public ProductEJB getProductEJB() {
        return productEJB;
    }

    public void setProductEJB(ProductEJB productEJB) {
        this.productEJB = productEJB;
    }

    public List<Product> getProductList() {
        productList = productEJB.findProducts();
        return productList;
    }

    public void setProductList(List<Product> productList) {
        this.productList = productList;
    }



}
